<?
/*
 *      add_tag.php
 *      
 *      Copyright 2011 Francesco Ricci <francesco@ricci.in>
 *      
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *      
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *      
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */

$db = mysql_connect(localhost, "root", "root") or die ("Errore!");
mysql_select_db("sms", $db);

$sql = "select * from tags where id_sms=".$_POST["id_sms"]." and id_tag=".$_POST["id_tag"];
$result = mysql_query($sql);
$numrows = mysql_num_rows($result);
if ($numrows==0)
{
	mysql_query("INSERT INTO tags VALUES (".$_POST["id_sms"].",".$_POST["id_tag"].")");
	echo 'Tagged!';
}
else
{
	echo 'Already tagged!';
}



?>
